# Forked from Alpine to apply Purism's mobile patches
pkgname=geary
pkgver=9999_git20201210
pkgrel=0
_commit="dd971251d7fd85c7b73f2e153beef9939354cec7"
pkgdesc="Geary is an email application built around conversations"
url="https://wiki.gnome.org/Apps/Geary"
# libhandy is not available on s390x or mips
arch="all !s390x !mips !mips64"
license="LGPL-2.1-or-later AND CC-BY-3.0 AND BSD-2-Clause"
depends="iso-codes dbus:org.freedesktop.Secrets"
makedepends="
	appstream-glib-dev
	cmake
	enchant2-dev
	folks-dev
	gcr-dev
	glib-dev
	gmime-dev
	gnome-online-accounts-dev
	gspell-dev
	gsound-dev
	gtk+3.0-dev
	iso-codes-dev
	itstool
	json-glib-dev
	libcanberra-dev
	libgee-dev
	libhandy1-dev
	libnotify-dev
	libpeas-dev
	libsecret-dev
	libunwind-dev
	libxml2-dev
	meson
	sqlite-dev
	vala
	webkit2gtk-dev
	ytnef-dev
	"
checkdepends="
	desktop-file-utils
	ibus
	xvfb-run
	"
options="!check" # https://gitlab.gnome.org/GNOME/geary/-/issues/776
subpackages="$pkgname-lang $pkgname-doc"
source="https://source.puri.sm/Librem5/geary/-/archive/$_commit/geary-$_commit.tar.gz"
builddir="$srcdir/$pkgname-$_commit"

prepare() {
	default_prepare
	# The branch of geary is from Purism's fork, which has all adaptive
	# patches in the /debian dir in this branch for generating a debian
	# package. There are dozens of patches, so we apply them here manually
	# (the location is not compatible with what abuild expects for package
	# patches).
	# Patches have to be applied in the order they are listed in
	# debian/pathes/series
	grep "\.patch$" debian/patches/series |xargs -I {} -t -r -n1 patch -p1 -i debian/patches/{}
}

build() {
	abuild-meson \
		-Dlibunwind_optional=true \
		-Dprofile=release \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	xvfb-run meson test --no-rebuild -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="f88317a690e8ea54572a3550738ccc1cec6f071e939c5cb857923c213db506ed16f249c980a2fc4a53af389ea5ebf001cfef60700623b7c9cc83f5baa79b3821  geary-dd971251d7fd85c7b73f2e153beef9939354cec7.tar.gz"
